<template>
  <div>
    <!-- increase(2)  可以传参 -->
    <button @click="increase()">加1</button>
    <button @click="decrease()">减1</button>
  </div>
</template>
<script>
import { mapMutations, mapActions } from "vuex";
export default {
  methods: {
    // addFn(){
    //     //调用store中的mutations里的increase方法 用commit()
    //     this.$store.commit('increase')
    // },
    // reduceFn(){//调用store中的actions里的decrease方法 dispatch()
    //     this.$store.dispatch('decrease')
    // }

    // add() {
    //   this.increase(3);
    // },

    ...mapMutations(["increase"]), //写需要用到的方法
    ...mapActions(["decrease"]),
  },
};
</script>